<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
        }

        .red {
            background-color: #f00;
            font-size: 24px;
            color: yellow;
        }
    </style>
  </head>
  <body>
    <div id="app">
        <button @click="isRed = !isRed">切换</button>

        <!-- 可以有固定的class，也可以再加动态class -->
        <div class="box" :class="{ red: isRed }">我是div</div>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            isRed: false
          }
        },
        methods: {
          
        }
      })
    </script>
  </body>
</html>